#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include "ns3/applications-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/on-off-helper.h"
#include "ns3/queue-disc.h"
#include "ns3/traffic-control-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/queue-disc.h"
#include "ns3/object.h"
#include "ns3/traced-value.h"
#include "ns3/trace-source-accessor.h"
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <fstream>

using namespace ns3;
std::string dir = "MixTraffic/";
// OutputStreamWrapper 输出文件流
// 平均队列长度 packets T = 1 s
static Ptr<OutputStreamWrapper> AverageQueueLengthStream;
// RTT(ms) X-tag = type
static Ptr<OutputStreamWrapper> QueueRTTStream;
// 吞吐量 (Mb/s) X-tag = type
static Ptr<OutputStreamWrapper> QueueThrougthOutStream;
// 吞吐量 (Mb/s) T = 1 s
static Ptr<OutputStreamWrapper> CPIE_QueueThrougthOutStream;
// 吞吐量 (Mb/s) T = 1 s
static Ptr<OutputStreamWrapper> PIE_QueueThrougthOutStream;
// 主动丢包 X-tag = type
static Ptr<OutputStreamWrapper> QueueActiveDropStream;
// 被动丢包 X-tag = type
static Ptr<OutputStreamWrapper> QueuePassiveDropStream;
// 平均延迟
static Ptr<OutputStreamWrapper> QueueMeanDelayStream;
// 延迟抖动
static Ptr<OutputStreamWrapper> QueueMeanJitterStream;
// 数据记录
// 平均队长
static void
AverageQueueLengthTracer(uint32_t oldValue, uint32_t newValue)

<<<<<<< HEAD
{
  *AverageQueueLengthStream->GetStream() << "len: " << newValue << std::endl;
}

static void
CPIE_QueueThrougthOutTracer(uint32_t oldValue, uint32_t newValue)
{
  // 吞吐量
  double Throughput = newValue * 8.0 / 1000000;
  // std::cout <<Simulator::Now ().GetSeconds ()<< "Throughput: " << Throughput << " Mbps" << std::endl;
  *CPIE_QueueThrougthOutStream->GetStream() << "CPIE_QueueThroughput: " << Throughput << std::endl;
}
static void
PIE_QueueThrougthOutTracer(uint32_t oldValue, uint32_t newValue)
{
  // 吞吐量
  double Throughput = newValue * 8.0 / 1000000;
  // std::cout << Simulator::Now ().GetSeconds ()<<"  Throughput: " << Throughput << " Mbps" << std::endl;
  *PIE_QueueThrougthOutStream->GetStream() << "PIE_QueueThroughput: " << Throughput << std::endl;
}

void experiment(std::string queueDiscType)
{
=======
void experiment(std::string queueDiscType)
{

>>>>>>> cukoo-counter-ns3-simulation/第二分支
  // 是否追踪
  bool isTracing = true;

  // 节点数设置为20
  uint32_t nodeLeafNum = 20;
  // TCP拥塞控制算法NewReno
  std::string tcpQueueType = "ns3::TcpNewReno";

  Ssid ssid = Ssid("wifi-default");
<<<<<<< HEAD
  // 路由器Router1和Router2之间的瓶颈链路带宽设置为10Mbps，链路传输时延设置为10ms
  std::string bottleNeckLinkBw = "10Mbps";
  std::string bottleNeckLinkDelay = "10ms";

  // CMD参数选择队列模式
  CommandLine cmd(__FILE__);
  cmd.AddValue("queueDiscType", "Set Queue disc type", queueDiscType);
  cmd.Parse(argc, argv);

=======

  std::string bottleNeckLinkBw = "10Mbps";
  std::string bottleNeckLinkDelay = "10ms";

>>>>>>> cukoo-counter-ns3-simulation/第二分支
  // 队列类型检查 CODEL DROPTAIL RED PIE CPIE
  if ((queueDiscType != "ns3::RedQueueDisc") && (queueDiscType != "ns3::CoDelQueueDisc") && (queueDiscType != "ns3::DropTailQueue") && (queueDiscType != "ns3::cPieQueueDisc") && (queueDiscType != "ns3::PieQueueDisc"))
  {
    std::cout << "Invalid queue disc type. Use --queueDiscType="
              << "ns3::RedQueueDisc, ns3::CoDelQueueDisc, ns3::DropTailQueue, "
              << "ns3::cPieQueueDisc, or ns3::PieQueueDisc." << std::endl;
    exit(1);
  }

  // RED 主动队列管理
  if (queueDiscType == "ns3::RedQueueDisc")
  {
    Config::SetDefault("ns3::RedQueueDisc::MaxSize",
                       QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, 100)));
    Config::SetDefault("ns3::RedQueueDisc::MinTh", DoubleValue(10.0));
    Config::SetDefault("ns3::RedQueueDisc::MaxTh", DoubleValue(30.0));
    Config::SetDefault("ns3::RedQueueDisc::QW", DoubleValue(0.02));
    Config::SetDefault("ns3::RedQueueDisc::LinkBandwidth", StringValue(bottleNeckLinkBw));
    Config::SetDefault("ns3::RedQueueDisc::LinkDelay", StringValue(bottleNeckLinkDelay));
    Config::SetDefault("ns3::RedQueueDisc::MeanPktSize", UintegerValue(512));
  }
  // CODEL 主动队列管理
  if (queueDiscType == "ns3::CoDelQueueDisc")
  {

    // * ``Interval:``  The default value is 100 ms.
    // * ``Target:`` The default value is 5 ms.
    Config::SetDefault("ns3::CoDelQueueDisc::MaxSize",
                       QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, 100)));
    Config::SetDefault("ns3::CoDelQueueDisc::Interval",
                       TimeValue(Seconds(0.1)));
    Config::SetDefault("ns3::CoDelQueueDisc::Target",
                       TimeValue(Seconds(0.005)));
  }
  // DROPTAIL 主动队列管理
  if (queueDiscType == "ns3::DropTailQueue")
  {
    Config::SetDefault("ns3::DropTailQueue<Packet>::MaxSize",
                       QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, 100)));
  }
  // PIE 主动队列管理
  if (queueDiscType == "ns3::PieQueueDisc")
  {
    // * ``A:`` Value of alpha. The default value is 0.125.
    // * ``B:`` Value of beta. The default value is 1.25.
    Config::SetDefault("ns3::PieQueueDisc::MaxSize",
                       QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, 100)));
    Config::SetDefault("ns3::PieQueueDisc::A", DoubleValue(0.125));
    Config::SetDefault("ns3::PieQueueDisc::B", DoubleValue(1.25));
    Config::SetDefault("ns3::PieQueueDisc::MeanPktSize", UintegerValue(512));
    // 阈值 30ms
    Config::SetDefault("ns3::PieQueueDisc::ActiveThreshold", TimeValue(Seconds(0.05)));
    Config::SetDefault("ns3::PieQueueDisc::QueueDelayReference", TimeValue(Seconds(0.02)));
    Config::SetDefault("ns3::PieQueueDisc::Tupdate", TimeValue(Seconds(0.03)));
  }
  // CPIE 主动队列管理
  if (queueDiscType == "ns3::cPieQueueDisc")
  {
    // * ``A:`` Value of alpha. The default value is 0.125.
    // * ``B:`` Value of beta. The default value is 1.25.
    Config::SetDefault("ns3::cPieQueueDisc::MaxSize",
                       QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, 100)));
    Config::SetDefault("ns3::cPieQueueDisc::A", DoubleValue(0.125));
    Config::SetDefault("ns3::cPieQueueDisc::B", DoubleValue(1.25));
    Config::SetDefault("ns3::cPieQueueDisc::MeanPktSize", UintegerValue(512));
    Config::SetDefault("ns3::cPieQueueDisc::ActiveThreshold", TimeValue(Seconds(0.05)));
    Config::SetDefault("ns3::cPieQueueDisc::QueueDelayReference", TimeValue(Seconds(0.02)));
    Config::SetDefault("ns3::cPieQueueDisc::Tupdate", TimeValue(Seconds(0.03)));
  }

<<<<<<< HEAD
=======
  // // 发送端统一部署了TCP拥塞控制算法NewReno
  // TypeId tcpTid;
  // NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(tcpQueueType, &tcpTid), "TypeId " << tcpQueueType << " not found");
  // Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue(TypeId::LookupByName(tcpQueueType)));
>>>>>>> cukoo-counter-ns3-simulation/第二分支

  // 创建结点
  NodeContainer UeNodes, ApNode, PcNode;
  UeNodes.Create(nodeLeafNum);
  ApNode.Create(1);
  PcNode.Create(1);

  // 连接AP与PC
  PointToPointHelper AP_PC_pointToPoint;
  AP_PC_pointToPoint.SetDeviceAttribute("DataRate", StringValue(bottleNeckLinkBw));
  AP_PC_pointToPoint.SetChannelAttribute("Delay", StringValue(bottleNeckLinkDelay));

  NetDeviceContainer Ap_Pc_Device;
  Ap_Pc_Device = AP_PC_pointToPoint.Install(ApNode.Get(0), PcNode.Get(0));

  // 建设Wifi信道
  YansWifiChannelHelper wifiChannel;
  wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
  wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel");

  // Set up Wi-Fi physical layer
  YansWifiPhyHelper wifiPhy;
  wifiPhy.SetChannel(wifiChannel.Create());
  wifiPhy.SetErrorRateModel("ns3::NistErrorRateModel");

  // Set up Wi-Fi MAC layer
  WifiMacHelper wifiMac;
  wifiMac.SetType("ns3::ApWifiMac", "Ssid", SsidValue(ssid));

  // Create Wi-Fi Helper
  WifiHelper wifiHelper;
  // Install Wi-Fi on AP
  NetDeviceContainer apDevice;
  apDevice = wifiHelper.Install(wifiPhy, wifiMac, ApNode.Get(0));

  // Set up mobility model for AP
  MobilityHelper mobility;
  Ptr<ListPositionAllocator> positionAllocAP = CreateObject<ListPositionAllocator>();
  positionAllocAP->Add(Vector(0.0, 0.0, 0.0));
  mobility.SetPositionAllocator(positionAllocAP);
  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.Install(ApNode);

  // Install Wi-Fi on UEs
  wifiMac.SetType("ns3::StaWifiMac", "Ssid", SsidValue(ssid));
  NetDeviceContainer UeDevices;
  UeDevices = wifiHelper.Install(wifiPhy, wifiMac, UeNodes);

  // Set up mobility model for UEs
<<<<<<< HEAD
  Ptr<ListPositionAllocator> positionAllocUEs = CreateObject<ListPositionAllocator>();
  for (uint32_t i; i < nodeLeafNum; i++)
  {
    double x = (rand() % 10) - i;
    double y = (rand() % 10) + i;
    positionAllocUEs->Add(Vector(x, y, 0.0));
=======

  Ptr<ListPositionAllocator> positionAllocUEs = CreateObject<ListPositionAllocator>();
  for (uint32_t i = 0; i < nodeLeafNum; i++)
  {

    positionAllocUEs->Add(Vector(1.0, 1.0, 1.0));
>>>>>>> cukoo-counter-ns3-simulation/第二分支
  }

  mobility.SetPositionAllocator(positionAllocUEs);
  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.Install(UeNodes);

  // 安装网络协议
  InternetStackHelper internet;
  internet.Install(UeNodes);
  internet.Install(ApNode);
  internet.Install(PcNode);

  // Set up queue management algorithms on AP
  TrafficControlHelper tch;
  tch.SetRootQueueDisc(queueDiscType);
<<<<<<< HEAD
  Ptr<QueueDisc> qdisc = tch.Install(Ap_Pc_Device);

   // 设置发送端使用NewReno
  for(uint32_t i = 0; i < UeNodes.GetN(); ++i){
        Ptr<Node> senderNode = UeNodes.Get (i);
        senderNode->GetObject<TcpL4Protocol>()->SetAttribute ("SocketType", TypeIdValue (TcpNewReno::GetTypeId ()));
  }
  

  // tch.Install(apDevice);
=======
  // 获取队列
  Ptr<QueueDisc> qdisc = tch.Install(Ap_Pc_Device.Get(0)).Get(0);

  // ApNode.Get (0)->GetObject<TcpL4Protocol>()->SetAttribute ("SocketType", TypeIdValue (TcpNewReno::GetTypeId ()));

  // 设置发送端使用NewReno
  for (uint32_t i = 0; i < UeNodes.GetN(); i++)
  {
    UeNodes.Get(i)->GetObject<TcpL4Protocol>()->SetAttribute("SocketType", TypeIdValue(TcpNewReno::GetTypeId()));
  }
>>>>>>> cukoo-counter-ns3-simulation/第二分支

  // Assign IP addresses for Wi-Fi devices
  Ipv4AddressHelper address;
  address.SetBase("10.1.1.0", "255.255.255.0");
  Ipv4InterfaceContainer apInterface;
  Ipv4InterfaceContainer ueInterface;
  apInterface = address.Assign(apDevice);
  ueInterface = address.Assign(UeDevices);

  // Assign IP addresses for Point-to-Point link
  address.SetBase("10.3.1.0", "255.255.255.0");
  Ipv4InterfaceContainer pcInterface;
  pcInterface = address.Assign(Ap_Pc_Device);

  Ipv4GlobalRoutingHelper::PopulateRoutingTables();

  ApplicationContainer receiveApps;
  Address sinkLocalAddress(InetSocketAddress(Ipv4Address::GetAny(), 5001));
  PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", sinkLocalAddress);
  // (为每个接收节点安装PacketSink)
  receiveApps.Add(packetSinkHelper.Install(PcNode));

  receiveApps.Start(Seconds(0.0));
  receiveApps.Stop(Seconds(10.0));

  // 发送数据包
<<<<<<< HEAD

  OnOffHelper sendOnOffHelper("ns3::TcpSocketFactory", Address());
  sendOnOffHelper.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
  sendOnOffHelper.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
  sendOnOffHelper.SetAttribute("PacketSize", UintegerValue(100));
  sendOnOffHelper.SetAttribute("DataRate", StringValue("100Mbps")); // bit/s
=======
  OnOffHelper sendOnOffHelper("ns3::TcpSocketFactory", Address());
  sendOnOffHelper.SetAttribute("PacketSize", UintegerValue(100));
  sendOnOffHelper.SetAttribute("DataRate", StringValue("100Mbps"));
  sendOnOffHelper.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]"));
  sendOnOffHelper.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]"));
>>>>>>> cukoo-counter-ns3-simulation/第二分支
  // 为每个发送节点安装OnOffApplication，并将目标地址设置为接收节点的IP和端口
  AddressValue remoteAddress(InetSocketAddress(pcInterface.GetAddress(1), 5001));
  sendOnOffHelper.SetAttribute("Remote", remoteAddress);

<<<<<<< HEAD
  // isTracing = false;
  // 记录数据
  if (isTracing)
  {
    qdisc->TraceConnectWithoutContext("PacketsInQueue", MakeCallback(&AverageQueueLengthTracer));

    // 时间为横轴
    if (queueDiscType == "ns3::cPieQueueDisc")
    {
      qdisc->TraceConnectWithoutContext("BytesInQueue", MakeCallback(&CPIE_QueueThrougthOutTracer));
      // 发送端
      ApplicationContainer sendApps;
      // 为每个发送节点安装OnOffApplication，并将目标地址设置为接收节点的IP和端口
      for (uint32_t i = 0; i < UeNodes.GetN(); ++i)
      {
        if (UeNodes.GetN() > nodeLeafNum - 5)
        {
          sendOnOffHelper.SetAttribute("DataRate", StringValue("130Mbps")); // bit/s
        }
        sendApps.Add(sendOnOffHelper.Install(UeNodes.Get(i)));
      }

      sendApps.Start(Seconds(1.0));
      sendApps.Stop(Seconds(9.0));
    }
    else if (queueDiscType == "ns3::PieQueueDisc")
    {
      qdisc->TraceConnectWithoutContext("BytesInQueue", MakeCallback(&PIE_QueueThrougthOutTracer));
      // 发送端
      ApplicationContainer sendApps;
      // 为每个发送节点安装OnOffApplication，并将目标地址设置为接收节点的IP和端口
      for (uint32_t i = 0; i < UeNodes.GetN(); ++i)
      {
        if (UeNodes.GetN() > nodeLeafNum - 5)
        {
          sendOnOffHelper.SetAttribute("DataRate", StringValue("130Mbps")); // bit/s
        }
        sendApps.Add(sendOnOffHelper.Install(UeNodes.Get(i)));
      }

      sendApps.Start(Seconds(1.0));
      sendApps.Stop(Seconds(9.0));
    }
    else
    {
      ApplicationContainer sendApps;
      sendApps = sendOnOffHelper.Install(UeNodes);
      sendApps.Start(Seconds(1.0));
      sendApps.Stop(Seconds(9.0));
    }
  }

// 流量分析
FlowMonitorHelper flowmon;
// Ptr<FlowMonitor> monitor = flowmon.Install(routers.Get(0));
Ptr<FlowMonitor> monitor = flowmon.InstallAll();

  // Run simulation
  Simulator::Stop(Seconds(10));
  Simulator::Run();
  if(isTracing){
  // 流量汇总
  std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats();

  double Throughput = stats[1].rxBytes * 8.0 / (stats[1].timeLastRxPacket.GetSeconds () - stats[1].timeFirstRxPacket.GetSeconds ()) / 1000000;
   // 吞吐量
  *QueueThrougthOutStream->GetStream () << queueDiscType <<"Throughput: " << Throughput << " Mbps"<<std::endl;
  // 平均延迟
  *QueueMeanDelayStream->GetStream () << queueDiscType <<  "MeanDelay: " << stats[1].delaySum.GetSeconds () / stats[1].rxPackets << std::endl;
  // 延迟抖动
  *QueueMeanJitterStream->GetStream () << queueDiscType << "MeanJitter: " << stats[1].jitterSum.GetSeconds () / (stats[1].rxPackets - 1) << std::endl;

  // Ipv4FlowProbe::DROP_QUEUE  被动
  uint32_t packetsDroppedByNetDevice = 0;
if (stats[1].packetsDropped.size () > Ipv4FlowProbe::DROP_QUEUE)
    {
      packetsDroppedByNetDevice = stats[1].packetsDropped[Ipv4FlowProbe::DROP_QUEUE];
    }

  // std::cout << "Packets Dropped by NetDevice:" << packetsDroppedByNetDevice<< std::endl;
  *QueuePassiveDropStream->GetStream () << queueDiscType <<"PacketsDroppedByNetDevice: " << packetsDroppedByNetDevice << std::endl;


  // Ipv4FlowProbe::DROP_QUEUE_DISC 主动丢包数
  uint32_t packetsDroppedByQueueDisc = 0;
  if (stats[1].packetsDropped.size () > Ipv4FlowProbe::DROP_QUEUE_DISC)
    {
      packetsDroppedByQueueDisc = stats[1].packetsDropped[Ipv4FlowProbe::DROP_QUEUE_DISC];
    }
  // std::cout << "Packets Dropped by Queue Disc:" << packetsDroppedByQueueDisc << std::endl;
  *QueueActiveDropStream->GetStream () << queueDiscType << "PacketsDroppedByQueueDisc:" << packetsDroppedByQueueDisc << std::endl;

}
 
  Simulator::Destroy();
}



int main (int argc, char **argv)
{

// 文本创建
  AsciiTraceHelper asciiTraceHelper;
  QueueThrougthOutStream= asciiTraceHelper.CreateFileStream ((dir+"QueueThrougthOut.txt").c_str ());
  QueueActiveDropStream= asciiTraceHelper.CreateFileStream ((dir+"QueueActiveDrop.txt").c_str ());
  QueuePassiveDropStream= asciiTraceHelper.CreateFileStream ((dir+"QueuePassiveDrop.txt").c_str ());
  CPIE_QueueThrougthOutStream= asciiTraceHelper.CreateFileStream ((dir+"CPIE_QueueThrougthOut.txt").c_str ());
  PIE_QueueThrougthOutStream= asciiTraceHelper.CreateFileStream ((dir+"PIE_QueueThrougthOut.txt").c_str ());
  QueueMeanDelayStream= asciiTraceHelper.CreateFileStream ((dir+"QueueMeanDelay.txt").c_str ());
  QueueMeanJitterStream= asciiTraceHelper.CreateFileStream ((dir+"QueueMeanJitter.txt").c_str ());


  std::cout << "Simulation with RedQueueDisc: Start\n" << std::flush;
  // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"red-rtt.txt").c_str ());
  AverageQueueLengthStream = asciiTraceHelper.CreateFileStream ((dir+"redAverageQueueLength.txt").c_str ());
  experiment ("ns3::RedQueueDisc");
  std::cout << "Simulation with RedQueueDisc: End\n" << std::flush;
  std::cout << "------------------------------------------------\n";


  std::cout << "Simulation with CoDelQueueDisc: Start\n" << std::flush;
  // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"codel-rtt.txt").c_str ());
    AverageQueueLengthStream = asciiTraceHelper.CreateFileStream ((dir+"codelAverageQueueLength.txt").c_str ());
  experiment ("ns3::CoDelQueueDisc");
  std::cout << "Simulation with CoDelQueueDisc: End\n" << std::flush;
  std::cout << "------------------------------------------------\n";

  // std::cout << "Simulation with DropTailQueue: Start\n" << std::flush;
    // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"droptail-rtt.txt").c_str ());
    //   AverageQueueLengthStream = asciiTraceHelper.CreateFileStream ((dir+"-aql.txt").c_str ());
  // experiment ("ns3::DropTailQueue");
  // std::cout << "Simulation with DropTailQueue: End\n" << std::flush;
  // std::cout << "------------------------------------------------\n";

  std::cout << "Simulation with cPieQueueDisc: Start\n" << std::flush;
    // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"cpie-rtt.txt").c_str ());
      AverageQueueLengthStream = asciiTraceHelper.CreateFileStream ((dir+"cpieAverageQueueLength.txt").c_str ());
  experiment ("ns3::cPieQueueDisc");
  std::cout << "Simulation with cPieQueueDisc: End\n" << std::flush;
=======
  // 发送端
  ApplicationContainer sendApps;
  sendApps.Add(sendOnOffHelper.Install(UeNodes));
  sendApps.Start(Seconds(1.0));
  sendApps.Stop(Seconds(9.0));

  // isTracing = false;
  // 记录数据
  if (isTracing)
  {
    wifiPhy.EnablePcap(dir + queueDiscType.substr(5) + "wifi-test", UeDevices.Get(1));
  }

  // Run simulation
  Simulator::Stop(Seconds(10.0));
  Simulator::Run();
  Simulator::Destroy();
}

int main(int argc, char **argv)
{
  std::cout << "Simulation with RedQueueDisc: Start\n"
            << std::flush;
  // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"red-rtt.txt").c_str ());
  AverageQueueLengthStream = asciiTraceHelper.CreateFileStream((dir + "redAverageQueueLength.txt").c_str());
  experiment("ns3::RedQueueDisc");
  std::cout << "Simulation with RedQueueDisc: End\n"
            << std::flush;
  std::cout << "------------------------------------------------\n";

  std::cout << "Simulation with CoDelQueueDisc: Start\n"
            << std::flush;
  // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"codel-rtt.txt").c_str ());
  AverageQueueLengthStream = asciiTraceHelper.CreateFileStream((dir + "codelAverageQueueLength.txt").c_str());
  experiment("ns3::CoDelQueueDisc");
  std::cout << "Simulation with CoDelQueueDisc: End\n"
            << std::flush;
  std::cout << "------------------------------------------------\n";

  // // std::cout << "Simulation with DropTailQueue: Start\n" << std::flush;
  //   // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"droptail-rtt.txt").c_str ());
  //   //   AverageQueueLengthStream = asciiTraceHelper.CreateFileStream ((dir+"-aql.txt").c_str ());
  // // experiment ("ns3::DropTailQueue");
  // // std::cout << "Simulation with DropTailQueue: End\n" << std::flush;
  // // std::cout << "------------------------------------------------\n";

  std::cout << "Simulation with cPieQueueDisc: Start\n"
            << std::flush;
  // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"cpie-rtt.txt").c_str ());
  AverageQueueLengthStream = asciiTraceHelper.CreateFileStream((dir + "cpieAverageQueueLength.txt").c_str());
  experiment("ns3::cPieQueueDisc");
  std::cout << "Simulation with cPieQueueDisc: End\n"
            << std::flush;
>>>>>>> cukoo-counter-ns3-simulation/第二分支
  std::cout << "------------------------------------------------\n";

  std::cout << "Simulation with PieQueueDisc: Start\n";
  // QueueRTTStream = asciiTraceHelper.CreateFileStream ((dir+"pie-rtt.txt").c_str ());
<<<<<<< HEAD
  AverageQueueLengthStream = asciiTraceHelper.CreateFileStream ((dir+"pieAverageQueueLength.txt").c_str ());
  experiment ("ns3::PieQueueDisc");
=======
  AverageQueueLengthStream = asciiTraceHelper.CreateFileStream((dir + "pieAverageQueueLength.txt").c_str());
  experiment("ns3::PieQueueDisc");
>>>>>>> cukoo-counter-ns3-simulation/第二分支
  std::cout << "Simulation with PieQueueDisc: End\n";
  return 0;
}

